;(function () {
  new Vue({
    el: '#preview-list',
    data: {
      data: {title: '', files: [], memo: ''},
      isImage: ['.jpg', '.jpeg', '.gif', '.png', '.bmp']
    },
    methods: {
      getinfo () {
        hlhttp.get({
          url: 'portal/consultation',
          data: {article_id: hlUrlUtil.GetQueryString('id')},
          success: (res) => {
            $('.html-preview').html(res.content)
            this.data.title = res.title
            res.attachmentsName.split(',').map((item, index) => {
              let type = item.substr(item.lastIndexOf('.'))
              if (this.isImage.indexOf(type) > -1) {
                this.data.files.push({name: item, url: res.attachmentsUrl.split(',')[index], type: 'pic'})
              }
              if (this.isImage.indexOf(type) == -1) {
                this.data.files.push({name: item, url: res.attachmentsUrl.split(',')[index], type: 'file'})
              }
            })
          }
        })
      },
      back () {
        hlUrlUtil.goTo('newszz',{ddtab: true},false)
        window.location.reload()
      }
    },
   
    mounted () {      
      if (hlUrlUtil.GetQueryString('id')) {
        this.getinfo()
				return
      }
			if (!hlUrlUtil.GetQueryString('clear')) {
				this.data = JSON.parse(window.sessionStorage.getItem('previewInfo'))
			  $('.html-preview').html(this.data.content)
			}
    }
  })
} ())
